#!/usr/bin/env python
# -*- coding:utf8 -*-
# uncompyle6 version 2.15.1
# Python bytecode 2.7 (62211)
# Decompiled from: Python 2.7.10 (default, Jul  1 2017, 13:36:56) 
# [GCC 4.4.6 20110731 (Red Hat 4.4.6-4)]
# Embedded file name: ./paas/conf/default.py
# Compiled at: 2017-11-16 15:44:28
"""
Tencent is pleased to support the open source community by making 蓝鲸智云(BlueKing) available.
Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

Django settings for paas project.

Generated by 'django-admin startproject' using Django 1.8.3.

For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
import os, sys, time
from django.utils.functional import SimpleLazyObject

try:
    import pymysql

    pymysql.install_as_MySQLdb()
except:
    pass

PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
PROJECT_ROOT, PROJECT_MODULE_NAME = os.path.split(PROJECT_PATH)
BASE_DIR = os.path.dirname(os.path.dirname(PROJECT_PATH))
SECRET_KEY = 'o7(025idh*fj@)ohujum-ilfxl^n=@d&$xz!_$$7s$8jopd5r#'
DEBUG = True
ALLOWED_HOSTS = [
    '*']
CSRF_COOKIE_NAME = 'bk_csrftoken'
INSTALLED_APPS = ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes',
                  'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles',
                  'account', 'app', 'release', 'engine', 'home', 'saas', 'resource',
                  'bk_app', 'esb.bkcore', 'esb.mainsite', 'esb.apps.manager', 'esb.apps.guide',
                  'esb.apps.bootstrapform')
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware', 'account.middlewares.LoginMiddleware',
'account.middlewares.DeveloperLimitMiddleware', 'common.middlewares.CheckXssMiddleware')
ROOT_URLCONF = 'urls'
MAKO_TEMPLATE_DIR = os.path.join(PROJECT_ROOT, 'templates')
MAKO_TEMPLATE_MODULE_DIR = os.path.join(PROJECT_ROOT, 'templates_module')
TEMPLATE_CONTEXT_PROCESSORS = ('django.template.context_processors.debug', 'django.core.context_processors.request',
                               'django.contrib.auth.context_processors.auth', 'django.core.context_processors.csrf',
                               'common.context_processors.site_settings', 'django.core.context_processors.i18n',
                               'django.contrib.messages.context_processors.messages')
TEMPLATES = [
    {'BACKEND': 'django.template.backends.django.DjangoTemplates',
     'DIRS': (
         os.path.join(PROJECT_ROOT, 'templates'),),
     'APP_DIRS': True,
     'OPTIONS': {'context_processors': list(TEMPLATE_CONTEXT_PROCESSORS)
                 }
     }]
SITE_URL = '/'
STATIC_URL = SITE_URL + 'static/'
STATICFILES_DIRS = (
    os.path.join(PROJECT_ROOT, 'static'),)
STATIC_VERSION = '0.0.9'
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
CSS_SUFFIX = 'min.css'
JS_SUFFIX = 'min.js'
CSRF_FAILURE_VIEW = 'account.views.csrf_failure'
LOGIN_URL = '/accounts/login/'
LOGOUT_URL = '/accounts/logout/'
LOGIN_REDIRECT_URL = SITE_URL
AUTH_USER_MODEL = 'account.BkUser'
AUTHENTICATION_BACKENDS = ('account.backends.BkBackend', 'django.contrib.auth.backends.ModelBackend')
REDIRECT_FIELD_NAME = 'c_url'
LOGIN_DOMAIN = ''
WSGI_APPLICATION = 'wsgi.application'
DATABASES = {'default': {'ENGINE': 'django.db.backends.sqlite3',
                         'NAME': os.path.join(BASE_DIR, 'db.sqlite3')
                         }
             }
LANGUAGE_CODE = 'zh-CN'
TIME_ZONE = 'Etc/GMT%+d' % ((time.altzone if time.daylight else time.timezone) / 3600)
USE_I18N = True
USE_L10N = True
BK_COOKIE_NAME = 'bk_token'
BK_COOKIE_AGE = 86400
EVENT_STATE_EXPIRE_SECONDS = 360
HISTORY_EVENT_STATE_EXPIRE_SECONDS = 900
USERNAME = 'admin'
PASSWORD = 'admin'
ENGINE_APP_INIT_URL = SimpleLazyObject(
    lambda: '%s/v1/apps/init' % getattr(sys.modules['settings'], 'ENGINE_HOST', 'http://127.0.0.1:8000'))
ENGINE_APP_RELEASE_URL = SimpleLazyObject(
    lambda: '%s/v1/apps/{app_code}/releases' % getattr(sys.modules['settings'], 'ENGINE_HOST', 'http://127.0.0.1:8000'))
ENGINE_APP_EVENT_LOGS_URL = SimpleLazyObject(
    lambda: '%s/v1/apps/{app_code}/events/{event_id}/logs' % getattr(sys.modules['settings'], 'ENGINE_HOST',
                                                                     'http://127.0.0.1:8000'))
ENGINE_APP_INFO_URL = SimpleLazyObject(
    lambda: '%s/v1/apps/{app_code}/info' % getattr(sys.modules['settings'], 'ENGINE_HOST', 'http://127.0.0.1:8000'))
ENGINE_AGENT_HEALTHZ_URL = SimpleLazyObject(
    lambda: '%s/v1/agents/healthz' % getattr(sys.modules['settings'], 'ENGINE_HOST', 'http://127.0.0.1:8000'))
ENGINE_SERVICE_STATUS_URL = SimpleLazyObject(
    lambda: '%s/v1/services/{category}/check/?server_id={server_id}' % getattr(sys.modules['settings'], 'ENGINE_HOST',
                                                                               'http://127.0.0.1:8000'))
APP_TEST_URL = SimpleLazyObject(
    lambda: 'http://%s/t/{app_code}/' % getattr(getattr(sys.modules['django.conf'], 'settings'), 'PAAS_DOMAIN'))
APP_PROD_URL = SimpleLazyObject(
    lambda: 'http://%s/o/{app_code}/' % getattr(getattr(sys.modules['django.conf'], 'settings'), 'PAAS_DOMAIN'))
HOST_CC = ''
HOST_JOB = ''
LOGGER_LEVEL = 'DEBUG'
LOGGING_DIR = os.environ.get('PAAS_LOGGING_DIR') or os.path.join(os.path.dirname(BASE_DIR), 'logs')
if not os.path.exists(LOGGING_DIR):
    os.mkdir(LOGGING_DIR)
LOG_CLASS = 'logging.handlers.RotatingFileHandler'
LOGGING = {'version': 1,
           'disable_existing_loggers': False,
           'formatters': {'verbose': {
               'format': '%(levelname)s [%(asctime)s] %(pathname)s %(lineno)d %(funcName)s %(process)d %(thread)d %(message)s ',
               'datefmt': '%Y-%m-%d %H:%M:%S'
               },
                          'simple': {'format': '%(levelname)s %(message)s '
                                     }
                          },
           'handlers': {'null': {'level': 'DEBUG',
                                 'class': 'django.utils.log.NullHandler'
                                 },
                        'console': {'level': 'DEBUG',
                                    'class': 'logging.StreamHandler',
                                    'formatter': 'simple'
                                    },
                        'root': {'class': LOG_CLASS,
                                 'formatter': 'verbose',
                                 'filename': os.path.join(LOGGING_DIR, 'paas.log'),
                                 'maxBytes': 10485760
                                 },
                        'wb_mysql': {'class': LOG_CLASS,
                                     'formatter': 'verbose',
                                     'filename': os.path.join(LOGGING_DIR, 'paas_mysql.log'),
                                     'maxBytes': 10485760
                                     }
                        },
           'loggers': {'django': {'handlers': [
               'null'],
               'level': 'ERROR',
               'propagate': True
           },
               'django.request': {'handlers': [
                   'console'],
                   'level': 'ERROR',
                   'propagate': True
               },
               'root': {'handlers': [
                   'root'],
                   'level': LOGGER_LEVEL,
                   'propagate': True
               },
               'django.db.backends': {'handlers': [
                   'wb_mysql'],
                   'level': 'ERROR',
                   'propagate': True
               }
           }
           }
